﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;

namespace EnCor.Config
{
    public class ModuleConfig : NameTypeConfigElement
    {
        [ConfigurationProperty(Constants.Config_Services)]
        public ServiceConfigCollection Services
        {
            get
            {
                return (ServiceConfigCollection)this[Constants.Config_Services];
            }
        }
        
        [ConfigurationProperty(Constants.Config_Type, DefaultValue= Constants.DefaultModuleType)]
        public override string TypeName
        {
            get
            {
                return (string)this[Constants.Config_Type];
            }
        }

        [ConfigurationProperty(Constants.Config_DataType, DefaultValue = Constants.DefaultModuleDataType)]
        public string DataTypeName
        {
            get
            {
                return (string)this[Constants.Config_DataType];
            }
        }

        public Type DataType
        {
            get
            {
                return Type.GetType(DataTypeName);
            }
        }

        protected override bool OnDeserializeUnrecognizedElement(string elementName, System.Xml.XmlReader reader)
        {
            return base.OnDeserializeUnrecognizedElement(elementName, reader);
        }



        public void DeserializeElement(System.Xml.XmlReader reader)
        {
            DeserializeElement(reader, false);
        }
    }
}
